﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using Maticsoft.DBUtility;

namespace Maticsoft.Web.CERTI
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                if (Session["u"] == null)
                {
                    //Response.Redirect("~/Login.aspx");
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "if(top){top.location.href='../Login.aspx'}else{location.href='../Login.aspx'};", true);
                }

            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtZSH.Text.Trim().Length == 0)
            {
                strErr += "证书号不能为空！\\n";
            }
            //if (this.txtJCS.Text.Trim().Length == 0)
            //{
            //    strErr += "金成色不能为空！\\n";
            //}
            //if (this.txtPM.Text.Trim().Length == 0)
            //{
            //    strErr += "品名不能为空！\\n";
            //}
            //if (this.txtJJZ.Text.Trim().Length == 0)
            //{
            //    strErr += "净金重不能为空！\\n";
            //}
            //if (this.txtBM.Text.Trim().Length == 0)
            //{
            //    strErr += "编码不能为空！\\n";
            //}
            //if (this.txtBZ.Text.Trim().Length == 0)
            //{
            //    strErr += "备注不能为空！\\n";
            //}
            
            
    //          <tr>
    //<td height="25" width="30%" align="right">
    //    创建时间
    //：</td>
    //<td height="25" width="*" align="left">
    //    <asp:TextBox id="txtCREATEDATE" runat="server" Width="200px"></asp:TextBox>
    //</td></tr>
    //<tr>
             
            //if (this.txtCREATEDATE.Text.Trim().Length == 0)
            //{
            //    strErr += "创建时间不能为空！\\n";
            //}

            //if (this.txtTEMP.Text.Trim().Length == 0)
            //{
            //    strErr += "临时信息不能为空！\\n";
            //}

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string ZSH = this.txtZSH.Text;
            string JCS = this.txtJCS.Text;
            string PM = this.txtPM.Text;
            string JJZ = this.txtJJZ.Text;
            string BM = this.txtBM.Text;
            string BZ = this.txtBZ.Text;
            //string CREATEDATE = this.txtCREATEDATE.Text;
            string TEMP = this.txtTEMP.Text;

            Maticsoft.Model.CERTI model = new Maticsoft.Model.CERTI();
            model.ZSH = ZSH;
            model.JCS = JCS;
            model.PM = PM;
            model.JJZ = JJZ;
            model.BM = BM;
            model.BZ = BZ;
            //model.CREATEDATE = CREATEDATE;
            model.TEMP = TEMP;

            Maticsoft.BLL.CERTI bll = new Maticsoft.BLL.CERTI();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
